package net.huashitong.supervision.gongjian.dao;

import com.sirdc.modules.core.dao.GenericQuery;
import com.sirdc.modules.core.dao.StringDao;
import com.sirdc.modules.utils.StringUtils;
import net.huashitong.supervision.gongjian.entity.project.ZhengQianEntity;
import net.huashitong.supervision.gongjian.filter.ZhengQianFilter;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class ZhengQianDao extends StringDao<ZhengQianEntity> {


    public List<ZhengQianEntity> getListNoPage(ZhengQianFilter filter){
        GenericQuery query =createQuery("obj");
        List<ZhengQianEntity> objects = query.listResult();
        return objects;

    }



    public List<ZhengQianEntity> getList(ZhengQianFilter filter){
        GenericQuery query =createQuery("obj");
        List<ZhengQianEntity> objects = query.listResult(filter);
        return objects;

    }


    public List<ZhengQianEntity> getLists(ZhengQianFilter filter){
        String hql = "select z " +
                "     from  ZhengQianEntity as z ,GjDeptProject as g " +
                "      where z.sysId=g.projectId ";
        GenericQuery query =create(hql);
        if(StringUtils.isNotBlank(filter.getDeptId()))
        {

            query.append(" and g.deptId=:deptId").setParam("deptId",filter.getDeptId());
        }
        query.append(" and g.deptType=:deptType").setParam("deptType",filter.getDeptType());
        List<ZhengQianEntity> objects = query.listResult(filter);
        return objects;

    }


}
